package com.example.gybicycle.service;

import com.example.gybicycle.common.entity.Result;
import com.example.gybicycle.common.sql.CrudService;
import com.example.gybicycle.dao.SysDictDao;
import com.example.gybicycle.entity.SysDict;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysDictService extends CrudService<SysDictDao, SysDict> {
    @Override
    public SysDict get(Integer id) {
        SysDict table=super.get(id);
        return table;
    }
    public Result save(SysDict entity,Integer loginId){

        int num=0;
        if(entity.getId()==null||entity.getId()==0){

            num=dao.insert(entity);
        }else {

            num=dao.update(entity);
        }
        if(num>0)
            return Result.success(entity);
        else 
            return Result.fail("保存失败");
    }
    public List<SysDict> findList(SysDict entity){
        List<SysDict> list=super.findList(entity);
        return list;
    }
    public String getLabel(String sign,Integer value){
        if(sign==null||value==null)
            return "";
        SysDict dict=new SysDict();
        dict.setSign(sign);
        dict.setValue(value);
        String label=dao.getLabel(dict);
        return label;
    }


}